home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / OOFILE AppMaker / FileAndFind / Pre-built version, as generated / CFileAndFindApp.cp < prev    next >
Text File  |  1995-09-30  |  4KB  |  190 lines

  1. // CFileAndFindApp.cp -- application methods
  2. // Created 01/01/95 12:01 PM by AppMaker
  3.  
  4. #include "CFileAndFindApp.h"
  5.  
  6. #include "CFileAndFindDoc.h"
  7. #include "CListArticles.h"
  8. #include "CAboutDialog.h"
  9. #include "CEditArticle.h"
  10.  
  11. #include <UDesktop.h>
  12. #include <URegistrar.h>
  13. #include <UScreenPort.h>
  14. #include <PPobClasses.h>
  15. #include <PP_Messages.h>
  16.  
  17. // ---------------------------------------------------------------------------
  18. //        • CFileAndFindApp
  19. // ---------------------------------------------------------------------------
  20. //    Default constructor
  21.  
  22. CFileAndFindApp::CFileAndFindApp()
  23.     :LDocApplication()
  24. {
  25.     UScreenPort::Initialize();
  26.  
  27.     RegisterClasses();
  28.  
  29.     SetUpMenus();
  30.  
  31.     // initialize app's data:
  32.  
  33. }
  34.  
  35.  
  36. // ---------------------------------------------------------------------------
  37. //        • ~CFileAndFindApp
  38. // ---------------------------------------------------------------------------
  39. //    Destructor
  40. //
  41.  
  42. CFileAndFindApp::~CFileAndFindApp()
  43. {
  44. }
  45.  
  46. // ---------------------------------------------------------------------------
  47. //        • RegisterClasses
  48. // ---------------------------------------------------------------------------
  49. //
  50.  
  51. void
  52. CFileAndFindApp::RegisterClasses()
  53. {
  54.     RegisterAllPPClasses();
  55.             // replace to register only classes that we use.
  56.             // windows know what classes they use
  57.             // so call static functions in each window/dialog,
  58.             // or generate a single function as union of all w/d's.
  59.  
  60.     // register custom pane classes
  61.     URegistrar::RegisterClass('Liss', (ClassCreatorFunc)CListArticles::CreateListArticlesStream);
  62.     URegistrar::RegisterClass('Abog', (ClassCreatorFunc)CAboutDialog::CreateAboutDialogStream);
  63.     URegistrar::RegisterClass('Edie', (ClassCreatorFunc)CEditArticle::CreateEditArticleStream);
  64. }
  65.  
  66. // ---------------------------------------------------------------------------
  67. //        • SetUpMenus
  68. // ---------------------------------------------------------------------------
  69. //
  70.  
  71. void
  72. CFileAndFindApp::SetUpMenus()
  73. {
  74.  
  75. }
  76.  
  77. // ---------------------------------------------------------------------------
  78. //        • StartUp
  79. // ---------------------------------------------------------------------------
  80. //    The application calls this member function automatically when the application
  81. //    is opened
  82.  
  83. void
  84. CFileAndFindApp::StartUp()
  85. {
  86.     ObeyCommand(cmd_Open, nil);
  87.     }
  88.  
  89.     //----------
  90.     LModelObject*
  91.     CFileAndFindApp::MakeNewDocument()
  92.     {
  93.     CFileAndFindDoc    *theDoc = new CFileAndFindDoc(this);
  94.  
  95.     theDoc->newFile();
  96.  
  97.     return theDoc;
  98. }
  99.  
  100. //----------
  101. // called from SendAEOpenDoc in response to Open command
  102.  
  103. void
  104. CFileAndFindApp::OpenDocument(
  105.     FSSpec    *inMacFSSpec)
  106. {
  107.     CFileAndFindDoc    *theDoc = new CFileAndFindDoc(this);
  108.  
  109.     theDoc->openFile (inMacFSSpec);
  110. }
  111.  
  112. //----------
  113. // called from LDocApplication in response to Open command
  114.  
  115. void
  116. CFileAndFindApp::ChooseDocument()
  117. {
  118.     SFTypeList            typeList;
  119.     short                numTypes;
  120.     StandardFileReply    macFileReply;
  121.  
  122.     typeList[0] = kFileType;
  123.     numTypes = 1;
  124.  
  125.     UDesktop::Deactivate();
  126.     ::StandardGetFile(nil, numTypes, typeList, &macFileReply);
  127.     UDesktop::Activate();
  128.  
  129.     if (macFileReply.sfGood) {
  130.         SendAEOpenDoc(macFileReply.sfFile);
  131.     }
  132. }
  133.  
  134. // ---------------------------------------------------------------------------
  135. //        • ObeyCommand
  136. // ---------------------------------------------------------------------------
  137. //    Respond to commands
  138.  
  139. Boolean
  140. CFileAndFindApp::ObeyCommand(
  141.     CommandT    inCommand,
  142.     void        *ioParam)
  143. {
  144.     Boolean    cmdHandled = true;
  145.  
  146.     switch (inCommand) {
  147.  
  148. case cmd_About:
  149. CAboutDialog::CreateAboutDialog(this);
  150. break;
  151.  
  152.     // +++ Add cases here for the commands you handle
  153.     //        Remember to add same cases to FindCommandStatus below
  154.     //        to enable/disable the menu items for the commands
  155.  
  156.     default:
  157.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  158.         break;
  159.     }
  160.  
  161.     return cmdHandled;
  162. }
  163.  
  164.  
  165. // ---------------------------------------------------------------------------
  166. //        • FindCommandStatus
  167. // ---------------------------------------------------------------------------
  168. //    Pass back status of a (menu) command
  169.  
  170. void
  171. CFileAndFindApp::FindCommandStatus(
  172.     CommandT    inCommand,
  173.     Boolean        &outEnabled,
  174.     Boolean        &outUsesMark,
  175.     Char16        &outMark,
  176.     Str255        outName)
  177. {
  178.     outUsesMark = false;
  179.  
  180.     switch (inCommand) {
  181.  
  182.     // +++ Add cases here for the commands you handle
  183.  
  184.     default:
  185.             LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  186.                                                 outMark, outName);
  187.         break;
  188.     }
  189. }
  190.